//提交评论
function submitComment(request_url) {
	var parentid = $("#commentForm input:hidden[name='parentid']").val();
	var objid = $("#commentForm input:hidden[name='objid']").val();
	var content = $("#commentForm textarea[name='content']").val();
	var recommend = $("#commentForm input:hidden[name='recommend']").val();
	
	if(content == '') {
		art.dialog.alert("您还未填写评语！");
		return false;
	}
	
	if(recommend == '') {
		art.dialog.alert("您还未评分！");
		return false;
	}
	
	$.ajax({
        type:"POST",
        dataType:'json',
        url:request_url,
        data:{parentid:parentid,
        	  objid:objid,
        	  content:content,
        	  recommend:recommend,},
        success:function(data){
        	if(data.status == '1') {
        		art.dialog({
	        	    icon: 'succeed',
	        	    content: data.info,
	        	    time:2
	        	});
        		location.reload(true);
        	} else {
        		art.dialog({
	        	    icon: 'error',
	        	    content: data.info,
	        	    time:2
	        	});
        	}
        },
        error:function(data){
        	art.dialog({
        	    icon: 'error',
        	    content: '评论失败！！！',
        	    time:2
        	});
        }
    });
}

//更新评论
function saveComment(request_url) {
	var id = $("#editForm input:hidden[name='id']").val();
	var content = $("#editForm textarea[name='content']").val();
	var recommend = $("#editForm input:hidden[name='recommend']").val();
	
	if(content == '') {
		art.dialog.alert("您还未填写评语！");
		return false;
	}
	
	if(recommend == '') {
		art.dialog.alert("您还未评分！");
		return false;
	}
	
	$.ajax({
        type:"POST",
        dataType:'json',
        url:request_url,
        data:{id:id,
        	  content:content,
        	  recommend:recommend,},
        success:function(data){
        	if(data.status == '1') {
        		art.dialog({
	        	    icon: 'succeed',
	        	    content: data.info,
	        	    time:2
	        	});
        		location.reload(true);
        	} else {
        		art.dialog({
	        	    icon: 'error',
	        	    content: data.info,
	        	    time:2
	        	});
        	}
        },
        error:function(data){
        	art.dialog({
        	    icon: 'error',
        	    content: '更新失败！！！',
        	    time:2
        	});
        }
    });
}
		
//对回复点赞或取消赞
function zan_comment(domid, request_url) {
	$.ajax({
        type:"POST",
        dataType:'json',
        url:request_url,
        success:function(data){
        	if(data.status == '1') {
        		if(data.data.type == 'zan') {
        			$("#"+domid).html('<i class="icon icon-thumbs-up"></i>取消赞('+data.data.zan_num+')');
        		} else if(data.data.type == 'cancel_zan') {
        			$("#"+domid).html('<i class="icon icon-thumbs-up"></i>赞('+data.data.zan_num+')');
        		}
        	} else {
        		art.dialog({
	        	    icon: 'error',
	        	    content: data.info,
	        	    time:2
	        	});
        	}
        },
        error:function(data){
        	art.dialog({
        	    icon: 'error',
        	    content: '操作失败！',
        	    time:2
        	});
        }
    });
}